WriterListLoader=function(){
	this.inited=false;
	this.appVM=null;
	this.options={};
}

WriterListLoader.defValue={
	appVMConfig:{
		el:"#writer-list-app",
		data:{
			writerList:[],
		}
	},
	itemContentEl:null,
	itemEl:".mui-table-view-cell",
	itemTapFunc:function(loader,tappedEle){
		loader.toDetailPage(tappedEle);
	},
	loadParam:{
		pageNo:1,
		pageSize:20,
	},
	loadOverCallback:function(){}
}
//
WriterListLoader.prototype.init=function(opts){
	var that=this;
	if(!this.inited){
		this.options=$.extend(true,{},WriterListLoader.defValue,opts);
		this.appVM=new Vue(this.options.appVMConfig);
		if(this.options.itemContentEl && this.options.itemTapFunc){
			$(this.options.itemContentEl).on('tap',this.options.itemEl,function(){
				//第二个参数为当前tap的元素
				that.options.itemTapFunc(that,this);
			});
		}
	}
	this.inited=true;
}
//
WriterListLoader.prototype.getLoadParam=function(){
	return this.options.loadParam;
}
//
WriterListLoader.prototype.getOptions=function(){
	return this.options;
}
//
WriterListLoader.prototype.loadWriterList=function(){
	var that=this;
	var appVMConfigData=this.options.appVMConfig.data;
	var url=getShiciServiceHost()+'/shici/writer/list';
	muiAjaxGetJsonData({
		url:url,
		data:that.options.loadParam,
		callback:function(data){
			if(data.entry){
				if(data.entry.dataList && data.entry.dataList.length>0){
					mui.each(data.entry.dataList,function(index,itemInfo){
					    if(itemInfo.simpleIntro){
							itemInfo.simpleIntro=itemInfo.simpleIntro.trim();
						}
					    appVMConfigData.writerList.push(itemInfo);
					});
				}
				that.options.loadOverCallback(that,data);
			}
		},
	});
}
//
WriterListLoader.prototype.emptyWriterList=function(){
	var appVMConfigData=this.options.appVMConfig.data;
	appVMConfigData.writerList = [];
}
//
WriterListLoader.prototype.toDetailPage=function(tappedEle){
	var index=$(tappedEle).attr('index');
	var dataList=this.options.appVMConfig.data.writerList;
	var indexData=dataList[index];
	var writerId=indexData.id;
	if(writerId){
		console.info(writerId);
		mui.openWindow({
			url:'writerDetail.html?writerId='+writerId,
			id:'writerDetail.html-writerId-'+writerId,
			extras:{
				writerId : writerId
			}
		});
	}
}